package com.lookoutthebush.companyindex.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户角色
 *
 * @author LookOutTheBush
 * @date 2021/9/22 12:07 下午
 */
@Getter
@AllArgsConstructor
public enum UserRoleEnum {

    /**
     * 普通用户
     */
    USER(0, "ROLE_USER"),
    /**
     * 管理员
     */
    ADMIN(1, "ROLE_ADMIN");

    private final Integer type;
    private final String role;

    public static String getRoleByType(Integer type){
        for (UserRoleEnum userRoleEnum : UserRoleEnum.values()){
            if(userRoleEnum.type.equals(type)){
                return userRoleEnum.role;
            }
        }
        return null;
    }
}
